import xlwt


def set_style(name, height, bold=False):
    style = xlwt.XFStyle()  # 初始化样式

    font = xlwt.Font()  # 为样式创建字体
    font.name = name  # 'Times New Roman'
    font.bold = bold
    font.colour_index = 4
    font.height = height

    style.font = font

    return style


# 写入excel
def write_excel():
    f = xlwt.Workbook()  # 创建工作簿
    sheet1 = f.add_sheet(u'sheet1', cell_overwrite_ok=True)  # 创建sheet
    row0 = [u'酒店名称', u'酒店位置', u'步行至地铁站距离', u'价格', u'商户星级', u'评价综述', u'酒店链接']
    # 生成第一行
    for i in range(0, len(row0)):
        sheet1.write(0, i, row0[i], set_style('Times New Roman', 220, True))
    
    f.save('dianping.xlsx')

if __name__ == '__main__':
    write_excel()
